#!/usr/bin/env python

from math import pi, e, sin, cos
from bernstein import interpolant2D, laplacian, basis_fun_eval, basis_fun_der

def rhs(x,y):
# Poisson equation
        return -(6*x*y*(1-y)-2*x**3) 


def lhs(i,j,n,m,x1,x2,y1,y2,x,y):
	return -laplacian(i,j,n,m,x1,x2,y1,y2,x,y)

def bc_left(x,y):
# Boundary condition for left edge of the rectangle
    return 0.

def bc_right(x,y):
# Boundary condition for right edge of the rectangle
    return y*(1-y)

def bc_top(x,y):
# Boundary condition for top edge of the rectangle
    return 0.

def bc_bottom(x,y):
# Boundary condition for bottom edge of the rectangle
    return 0.

def Dirichlet(i,j,n,m,x1,x2,y1,y2,x,y):
# Matrix entry for Dirichlet BCs:
    return basis_fun_eval(i,n,x1,x2,x)*basis_fun_eval(j,m,y1,y2,y)

def Neumann_y_dir(i,j,n,m,x1,x2,y1,y2,x,y):
# Matrix entry for Neumann BCs:
    return basis_fun_eval(i,n,x1,x2,x)*basis_fun_der(1,j,m,y1,y2,y)

def Mixed(i,j,n,m,x1,x2,y1,y2,x,y):
# Matrix entry for mixed (Robin) BCs:
    return 0.
